import variables from '@/styles/element-variables.scss'
const state = {
    isCollapse: false,//是否折叠菜单
    currentMenu: '',//高亮菜单
    color: variables.color
}

const mutations = {
    TOGGLE_SIDEBAR(state) {
        state.isCollapse = !state.isCollapse
    },
    SET_CURRENTMENU(state, currentMenu) {
        state.currentMenu = currentMenu
    },
    CHANGE_SETTING: (state, { key, value }) => {
        if (state.hasOwnProperty(key)) {
            state[key] = value
        }
    }

}

const actions = {
    toggleSideBar({ commit }) {
        commit('TOGGLE_SIDEBAR')
    },
    setCurrentMenu({ commit }, currentMenu) {
        commit('SET_CURRENTMENU', currentMenu)
    },
    changeSetting({ commit }, data) {
        commit('CHANGE_SETTING', data)
    }
}


export default {
    state,
    mutations,
    actions
}